﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ISS.IR.RRNMS.Library.DataAccess;

namespace ISS.IR.RRNMS.Library.BusinessLogic
{
    public class Account
    {
        public Guid AccountId { get; set; }

        public string FirstName { get; set; }
        public string SecondName { get; set; }
        public string ThirdName { get; set; }
        public string FourthName { get; set; }

        public string FullName { get; set; }

        public string UNHCR { get; set; }

        public Item Gender { get; set; }

        public string Telephone { get; set; }
        public string Email { get; set; }
        public string AddressInEgypt { get; set; }

        public Item Governorate { get; set; }
        public Item Region { get; set; }
        public DateTime BirthDate { get; set; }
        public string BirthPlace { get; set; }

        public Item MaritalStatus { get; set; }
        public int FamilyMembersCount { get; set; }
        public int InfantsCount { get; set; }

        public bool IsInEmergency { get; set; }
        public string EmergencyDescription { get; set; }

        public bool WasDetainedInEgypt { get; set; }
        public string DetentionInEgyptDescription { get; set; }

        public bool WasDetainedInHomeCountry { get; set; }
        public string DetentionInHomeCountryDescription { get; set; }

        public decimal AverageMonthlyIncome { get; set; }
        public string OtherIncomeSource { get; set; }
        public decimal LeaseAmount { get; set; }
        public decimal FoodAmount { get; set; }
        public decimal ElectricityAmount { get; set; }
        public decimal WaterAmount { get; set; }
        public decimal GasAmount { get; set; }
        public decimal EducationAmount { get; set; }
        public decimal MedicineAmount { get; set; }
        public decimal OtherAmount { get; set; }

        public int NumberOfRooms { get; set; }
        public bool HasElectricity { get; set; }
        public bool HasDrinkingWater { get; set; }
        public bool HasSanitation { get; set; }
        public bool HasFurniture { get; set; }
        public Item LivingStatus { get; set; }
        public string JobDescriptionInHomeCountry { get; set; }
        public string TrainingCoursesWantedInEgypt { get; set; }
        public string JobWantedInEgypt { get; set; }

        public Item ChronicDisease { get; set; }
        public string ChronicDiseaseOther { get; set; }

        public bool HasDisability { get; set; }
        public bool IsDisabilityMedicalReportAttached { get; set; }

        public bool HasPsychiatricDisease { get; set; }
        public bool IsPsychiatricDiseaseMedicalReportAttached { get; set; }

        public bool IsPregnant { get; set; }
        public bool IsPregnantMedicalReportAttached { get; set; }

        public bool HasPregnancyProblems { get; set; }
        public bool IsPregnancyProblemsMedicalReportAttached { get; set; }

        public string InterviewSummary { get; set; }

        public bool IsAction1 { get; set; }
        public string Action1Description { get; set; }

        public bool IsAction2 { get; set; }
        public string Action2Description { get; set; }

        public bool IsAction3 { get; set; }
        public string Action3Description { get; set; }

        public bool IsAction4 { get; set; }
        public string Action4Description { get; set; }

        public bool IsAction5 { get; set; }
        public string Action5Description { get; set; }

        public bool IsAction6 { get; set; }
        public string Action6Description { get; set; }

        public bool IsAction7 { get; set; }
        public string Action7Description { get; set; }

        public bool IsAction8 { get; set; }
        public string Action8Description { get; set; }

        public bool IsAction9 { get; set; }
        public string Action9Description { get; set; }

        public bool IsAction10 { get; set; }
        public string Action10Description { get; set; }

        public bool IsAction11 { get; set; }
        public string Action11Description { get; set; }

        public string SocialWorkerDecisionCode { get; set; }
        public string SocialWorkerDecisionDescription { get; set; }

        public string CommitteeDecision { get; set; }

        public Item AidType { get; set; }

        public decimal AidAmount { get; set; }
        public int AidMonths { get; set; }
        public string AidCode { get; set; }
        public string AidOther { get; set; }

        public List<SubAccount> SubAccounts {get; set;}

        public Account(Guid AccountId)
        {
            Account temp = Main.GetAccountById(AccountId);
            CopyAccount(temp);
        }

        public Account(string UNHCR)
        {
            Account temp = Main.GetAccountByUNHCR(UNHCR);
            CopyAccount(temp);
        }

        private void CopyAccount(Account tempAccount)
        {

            this.AccountId = tempAccount.AccountId;

            this.FirstName = tempAccount.FirstName;
            this.SecondName = tempAccount.SecondName;
            this.ThirdName = tempAccount.ThirdName;
            this.FourthName = tempAccount.FourthName;

            this.FullName = tempAccount.FullName;

            this.UNHCR = tempAccount.UNHCR;

            this.Gender = tempAccount.Gender;

            this.Telephone = tempAccount.Telephone;
            this.Email = tempAccount.Email;
            this.AddressInEgypt = tempAccount.AddressInEgypt;

            this.Governorate = tempAccount.Governorate;

            this.Region = tempAccount.Region;

            this.BirthDate = tempAccount.BirthDate;
            this.BirthPlace = tempAccount.BirthPlace;

            this.MaritalStatus = tempAccount.MaritalStatus;
            this.FamilyMembersCount = tempAccount.FamilyMembersCount;
            this.InfantsCount = tempAccount.InfantsCount;

            this.IsInEmergency = tempAccount.IsInEmergency;
            this.EmergencyDescription = tempAccount.EmergencyDescription;

            this.WasDetainedInEgypt = tempAccount.WasDetainedInEgypt;
            this.DetentionInEgyptDescription = tempAccount.DetentionInEgyptDescription;

            this.WasDetainedInHomeCountry = tempAccount.WasDetainedInHomeCountry;
            this.DetentionInHomeCountryDescription = tempAccount.DetentionInHomeCountryDescription;

            this.AverageMonthlyIncome = tempAccount.AverageMonthlyIncome;
            this.OtherIncomeSource = tempAccount.OtherIncomeSource;
            this.LeaseAmount = tempAccount.LeaseAmount;
            this.FoodAmount = tempAccount.FoodAmount;
            this.ElectricityAmount = tempAccount.ElectricityAmount;
            this.WaterAmount = tempAccount.WaterAmount;
            this.GasAmount = tempAccount.GasAmount;
            this.EducationAmount = tempAccount.EducationAmount;
            this.MedicineAmount = tempAccount.MedicineAmount;
            this.OtherAmount = tempAccount.OtherAmount;

            this.NumberOfRooms = tempAccount.NumberOfRooms;
            this.HasElectricity = tempAccount.HasElectricity;
            this.HasSanitation = tempAccount.HasSanitation;
            this.HasFurniture = tempAccount.HasFurniture;
            this.HasDrinkingWater = tempAccount.HasDrinkingWater;
            this.LivingStatus = tempAccount.LivingStatus;


            this.JobDescriptionInHomeCountry = tempAccount.JobDescriptionInHomeCountry;
            this.TrainingCoursesWantedInEgypt = tempAccount.TrainingCoursesWantedInEgypt;
            this.JobWantedInEgypt = tempAccount.JobWantedInEgypt;

            this.ChronicDisease = tempAccount.ChronicDisease;

            this.ChronicDiseaseOther = tempAccount.ChronicDiseaseOther;

            this.HasDisability = tempAccount.HasDisability;
            this.IsDisabilityMedicalReportAttached = tempAccount.IsDisabilityMedicalReportAttached;

            this.HasPsychiatricDisease = tempAccount.HasPsychiatricDisease;
            this.IsPsychiatricDiseaseMedicalReportAttached = tempAccount.IsPsychiatricDiseaseMedicalReportAttached;

            this.IsPregnant = tempAccount.IsPregnant;
            this.IsPregnantMedicalReportAttached = tempAccount.IsPregnantMedicalReportAttached;

            this.HasPregnancyProblems = tempAccount.HasPregnancyProblems;
            this.IsPregnancyProblemsMedicalReportAttached = tempAccount.IsPregnancyProblemsMedicalReportAttached;

            this.InterviewSummary = tempAccount.InterviewSummary;

            this.IsAction1 = tempAccount.IsAction1;
            this.Action1Description = tempAccount.Action1Description;

            this.IsAction2 = tempAccount.IsAction2;
            this.Action2Description = tempAccount.Action2Description;

            this.IsAction3 = tempAccount.IsAction3;
            this.Action3Description = tempAccount.Action3Description;

            this.IsAction4 = tempAccount.IsAction4;
            this.Action4Description = tempAccount.Action4Description;

            this.IsAction5 = tempAccount.IsAction5;
            this.Action5Description = tempAccount.Action5Description;

            this.IsAction6 = tempAccount.IsAction6;
            this.Action6Description = tempAccount.Action6Description;

            this.IsAction7 = tempAccount.IsAction7;
            this.Action7Description = tempAccount.Action7Description;

            this.IsAction8 = tempAccount.IsAction8;
            this.Action8Description = tempAccount.Action8Description;

            this.IsAction9 = tempAccount.IsAction9;
            this.Action9Description = tempAccount.Action9Description;

            this.IsAction10 = tempAccount.IsAction10;
            this.Action10Description = tempAccount.Action10Description;

            this.IsAction11 = tempAccount.IsAction11;
            this.Action11Description = tempAccount.Action11Description;

            this.SocialWorkerDecisionCode = tempAccount.SocialWorkerDecisionCode;
            this.SocialWorkerDecisionDescription = tempAccount.SocialWorkerDecisionDescription;

            this.CommitteeDecision = tempAccount.CommitteeDecision;

            this.AidType = tempAccount.AidType;
            this.AidAmount = tempAccount.AidAmount;
            this.AidMonths = tempAccount.AidMonths;
            this.AidCode = tempAccount.AidCode;
            this.AidOther = tempAccount.AidOther;

            this.SubAccounts = tempAccount.SubAccounts;
        }
        public Account()
        {

        }

        public static InitialLookups GetInitialLookupsForAccounts()
        {
            return Main.GetInitialLookupsForAccounts();
        }

        public void Save()
        {
            Main.SaveAccount(this);
        }

        public static List<Item> GetAllAccounts()
        {
            return Main.SelectListOfAllAccounts();
        }
    }

    public struct InitialLookups
    {
        public List<Item> Genders;
        public List<Item> Governorates;
        public List<Item> Regions;
        public List<Item> MaritalStatuses;
        public List<Item> LivingStatuses;
        public List<Item> ChronicDiseases;
        public List<Item> AidTypes;
        public List<Item> SubAccountRelationship;
    }
}
